<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gym Rat | Routines</title>
<script type="text/javascript"
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
	</script>
<script type="text/javascript">

</script>
</head>

<body>
<jsp:include page="/includes/nav.jsp" />
<c:if test="${result != null}">
${result}<br>
</c:if>
<h1>Full Routine List</h1>
<p>Select a routine from the list below to log a workout. You can
also use the edit link to modify a workout, <a
	href="<c:url value='/routine/create.jsp' />">Create a New Routine</a>,
or <a href="<c:url value='/routine/search' />">Search for a New
Routine</a><br><a href="<c:url value='/program/create.jsp' />">Create a Program</a></p>
<table width="100%">
	<tr class="tableHeader">
		<td>Name</td>
		<td>Description</td>
		<td>Author</td>
		<td>Options</td>
	</tr>

	<c:if test="${routines != null}">
		<c:forEach var="routine" items="${routines}" varStatus="status">
			<c:choose>
				<c:when test="${status.count % 2 == 1 }">
					<c:set var="rowClass" value="tableOddRow" />
				</c:when>
				<c:otherwise>
					<c:set var="rowClass" value="tableEvenRow" />
				</c:otherwise>
			</c:choose>
			<tr class="${rowClass }">
				<td><a
					href="<c:url value='/log/add?routineid=${routine.id}' />">${routine.name}</a>
				<c:if test="${routine.shared == true}">
					 (Shared with ${routine.users } users)</c:if> <c:if
					test="${routine.sourceId != 0 }">My vote: ${routine.myVote}-
					 Public Routine ( <a onClick="$('#voteup${routine.id}').submit()">Vote
					up</a>
					 | <a onClick="$('#votedown${routine.id}').submit()">Vote down</a>
				</c:if></td>
				<td>${routine.description}</td>
				<td>${routine.author}</td>
				<td><a
					href="<c:url value='/routine/modify?id=${routine.id}' />">edit</a>
				<form id="voteup${routine.id}" action="vote" method="post"><input
					type="hidden" name="id" value="${routine.sourceId }"> <input
					type="hidden" name="vote" value="1"></form>
				<form id="votedown${routine.id}" action="vote" method="post"><input
					type="hidden" name="id" value="${routine.sourceId }"> <input
					type="hidden" name="vote" value="-1"></form>
				</td>
			</tr>

		</c:forEach>
	</c:if>
</table>


<hr />
<a href="<c:url value='/routine/create.jsp' />">Create New Routine</a>
<br>
<a href="<c:url value='/routine/search' />">Search for a New Routine</a>
</body>
</html>